<?php
/*
# $Id$
*/

/*
# @class ModelCollection
# An array substitute which provides a few additional methods
# for performing some db actions on a group of Models.
#
# NOTE:
# Won't be able to perform certain functions such as implode() on instances.
*/
class ModelCollection implements Iterator, ArrayAccess, Countable {

	private $models;

	public function __construct($models) {
		$this->models = $models;
	}

	public function rewind() {
		return reset($this->models);
	}

	public function next() {
		return next($this->models);
	}

	public function valid() {
		return current($this->models)==TRUE ? TRUE : FALSE;
	}

	public function current() {
		return current($this->models);
	}

	public function key() {
		return key($this->models);
	}

	public function offsetExists($o) {
		return isset($this->models[$o]);
	}

	public function offsetSet($o, $v) {
		$this->models[$o] = $v;
	}

	public function offsetGet($o) {
		return $this->models[$o];
	}

	public function offsetUnset($o) {
		unset($this->models[$o]);
	}

	public function count() {
		return count($this->models);
	}
}
?>